<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.google.appengine.api.blobstore.BlobstoreService" %>
<%@ page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %>

<!DOCTYPE html>
<html>
<head>
  <link type="text/css" href="css/smoothness/jquery-ui-1.9.1.custom.css" rel="stylesheet" />
  <script src="js/jquery-1.8.2.js"></script>
  <script src="js/jquery-ui-1.9.1.custom.js"></script>
  <script src="/nose.js"></script>
  <style>
  	#uppost{
  		background-color: #666666;
  		color: #ffffff;
  		margin: 10px, 50px;
  	}
  	.formheader{
  		width: 120px;
  		height: 30px;
  		font-size: 15px;
  	}
  </style>
  <script>
  function checkform(f){
		t = $("#topic")[0];	
		if(t.value=="" || t==null){
	  		alert("please give a topic");
	  		return false;
	  	}
	  	f1 = $("#upimg1")[0];
	  	f2 = $("#upimg2")[0];
	  	if(f1.files[0]!=null)
	  	if(f1.files[0].size > 1024*1024){
	  		alert("first file size < 1MB please");
	  		return false;
	  	}
	  	if(f2.files[0]!=null)
	  		if(f2.files[0].size > 1024*1024){
	  			alert("second file size < 1MB please");
	  	  		return false;
	  	  	}
	  	return true;
	}
  </script>
</head>

<body leftmargin="20px" topmargin="20px" marginwidth="20px" marginheight="20px">

<%
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	if (user == null) {
        response.sendRedirect(userService.createLoginURL(request.getRequestURI()));
    }
	
	BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
%>

<form name="uppost" id="uppost"  action="<%= blobstoreService.createUploadUrl("/votepost") %>" method="post"  enctype="multipart/form-data" onsubmit="return checkform(this);">
	<div class="formheader">Topic</div> <input name="topic" id="topic" type="text"/><br>
   	<div class="formheader">Image 1</div> <input name="upimg1" id="upimg1" type="file"/><br>
    <div class="formheader">Image 2</div> <input name="upimg2" id="upimg2" type="file"/><br>
    <br>
	<input name="uid" type="hidden" value="<%= user.getUserId() %>"/>
	<input  name="reallyup" id="reallyup" type="submit" value="upload"/>
	<br>
</form>
<script>
	$("#reallyup").button();
	$(".formheader").button();
</script>
  
</body>
</html>
